package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.WechatArticle;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WechatArticleDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "文章标题")
    private String title;

    @ApiModelProperty(value = "文章内容")
    private String content;

    @ApiModelProperty(value = "图文消息的封面素材id")
    private String thumbMediaId;

    @ApiModelProperty(value = "摘要")
    private String digest;

    @ApiModelProperty(value = "作者")
    private String author;

    @ApiModelProperty(value = "图文消息的原文地址，即点击“阅读原文”后的URL")
    private String contentSourceUrl;

    @ApiModelProperty(value = "是否打开评论，0不打开(默认)，1打开")
    private Integer needOpenComment;

    @ApiModelProperty(value = "是否粉丝才可评论，0所有人可评论(默认)，1粉丝才可评论")
    private Integer onlyFansCanComment;

    @ApiModelProperty(value = "文章media_id")
    private String mediaId;

    @ApiModelProperty(value = "素材url")
    private String imgUrl;

    @ApiModelProperty(value = "发布状态：0未发布，1发布成功，2发布未通过")
    private Integer status;

    @ApiModelProperty(value = "排序字段: 修改时，为0则是排在最前面")
    private Integer sort;

    @ApiModelProperty(value = "排序字段: 发布回调id")
    private String publishId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;


    public WechatArticleDTO() {}

    public WechatArticleDTO(WechatArticle entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static WechatArticleDTO convert(WechatArticle entity) {
        return new WechatArticleDTO(entity);
    }

    public static List<WechatArticleDTO> convertList(List<WechatArticle> list) {
        List<WechatArticleDTO> resultList = new ArrayList<>();
        for (WechatArticle entity : list) {
            resultList.add(new WechatArticleDTO(entity));
        }
        return resultList;
    }}
